<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/23
 * Time: 14:01
 */
namespace app\api\controller\v1;

use app\api\model\Banner as BannerModel;
use app\api\validate\IDMustPositveInt;
use app\lib\exception\BannerMissException;
use think\Controller;

class Banner extends Controller{

    /**
     * 获取指定ID的Banner信息
     * @param $id
     *
     * @return \think\response\Json
     * @throws BannerMissException
     * @throws \app\lib\exception\ParemeterException
     */
    public function getBanner($id) {
//        AOP面向切面编程
        (new IDMustPositveInt())->goCheck();
        $banner = BannerModel::getBannerByID($id);
        if(!$banner){
            throw new BannerMissException();
        }
//        return json(['code'=>200,'msg'=>'OK','data'=>$banner]);
        return $banner;
    }

}


















